package net.kong.sns.rest.client.friend.json;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import net.kong.sns.rest.client.model.UserRelation;
import net.kong.sns.rest.client.model.UserRelation.RELATION_TYPE;
import net.kong.sns.rest.client.ClientTestBase;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;


/**
 * @author yk
 * @version $Id: Friends_AreFriends.java,v 1.6 2009/11/04 13:26:21 ningyubin Exp $
 */
@RunWith(Parameterized.class)
public class Friends_AreFriends extends ClientTestBase {

    private Collection<Long> userIds1;

    private Collection<Long> userIds2;

    private String p_userIds1;

    private String p_userIds2;

    private List<UserRelation> friends_areFriends_ret;

    public Friends_AreFriends(
            String file,
            Collection<Long> userIds1,
            Collection<Long> userIds2,
            List<UserRelation> friends_areFriends_ret,
            String p_userIds1,
            String p_userIds2) {
        super(Friend_Get_Id.class.getResourceAsStream(file));
        this.userIds1 = userIds1;
        this.userIds2 = userIds2;
        this.friends_areFriends_ret = friends_areFriends_ret;
        this.p_userIds1 = p_userIds1;
        this.p_userIds2 = p_userIds2;
    }

    @Parameters
    public static Collection<Object[]> testData() {
        return Arrays.asList(new Object[][]{
                {"Friends_AreFriends_1.xml"
                        , new ArrayList<Long>() {{
                    add(11L);
                    add(22L);
                    add(33L);
                }}
                        , new ArrayList<Long>() {{
                    add(111L);
                    add(222L);
                    add(333L);
                }}
                        , new ArrayList<UserRelation>() {
                    {
                        add(new UserRelation(11, 111, RELATION_TYPE.FRIEND));
                        add(new UserRelation(22, 222, RELATION_TYPE.STROMGER));
                        add(new UserRelation(33, 333, RELATION_TYPE.BLACK));
                    }
                },
                        "11,22,33",
                        "111,222,333"
                }
        }
        );
    }

    @Test
    public void friends_areFriends() {
        List<UserRelation> ret = client.friends_areFriends(userIds1, userIds2);
        Assert.assertEquals(friends_areFriends_ret, ret);
        Assert.assertEquals(p_userIds1, ((Object[]) parameterMap.get("user_ids1"))[0]);
        Assert.assertEquals(p_userIds2, ((Object[]) parameterMap.get("user_ids2"))[0]);
        Assert.assertEquals("json", ((String[]) parameterMap.get("response_format"))[0]);
        Assert.assertEquals("1.0", ((String[]) parameterMap.get("v"))[0]);
    }
}
